﻿//JumbotCms_4.1 Final
using System;
using System.Web;
using System.Data;
using Jumbot.Common;
using JumbotCms.Common;
namespace JumbotCms.WebFile.MTag
{
    public partial class _view_memberlist_ajax : JumbotCms.API.UserCenter
    {
        private string _operType = string.Empty;
        private string _response = string.Empty;

        protected void Page_Load(object sender, EventArgs e)

        {
            if (!CheckFormUrl())
            {
                Response.Write("提交有误");
                Response.End();
            }

            this._operType = q("oper");
            switch (this._operType)
            {
                case "ajaxGetList":
                    ajaxGetList();
                    break;
                default:
                    DefaultResponse();
                    break;
            }
            Response.Write(this._response);
        }
        private void DefaultResponse()
        {
            User_Load("", "json");
        }
        private void ajaxGetList()
        {
            User_Load("", "json");
            int page = Int_ThisPage();
            int PSize = Str2Int(q("pagesize"), 10);
            int countNum = 0;
            string sqlStr = "";
            string joinStr = "a.UserId=B.Id";
            string whereStr1 = "A.mtagid=" + Str2Str(q("mtagid"));
            string whereStr2 = "mtagid=" + Str2Str(q("mtagid"));
            string sort = Str2Str(q("sort"));
            if (sort != "0")
            {
                switch (sort)
                {
                    case "1"://Power=8,9
                        whereStr1 += " AND A.Power>=8";
                        whereStr2 += " AND Power>=8";
                        break;
                    case "2"://Power=0
                        whereStr1 += " AND A.Power=-0";
                        whereStr2 += " AND Power=0";
                        break;
                    case "3"://Power=-1
                        whereStr1 += " AND A.Power=-1";
                        whereStr2 += " AND Power=-1";
                        break;
                    case "4"://Power=-2
                        whereStr1 += " AND A.Power=-2";
                        whereStr2 += " AND Power=-2";
                        break;
                }
            }
            doh.Reset();
            doh.ConditionExpress = whereStr2;
            countNum = doh.Count("jcms_normal_mtag_member");
            sqlStr = Jumbot.Common.staticFunction.GetSql("a.id as memberid,a.UserId as memberuserid,a.Power as memberPower,a.MTagId as memberMTagId,b.UserName as memberusername,b.ComeFrom as memberComeFrom", "jcms_normal_mtag_member", "jcms_normal_user", "Id", PSize, page, "asc", joinStr, whereStr1, whereStr2);
            doh.Reset();
            doh.SqlCmd = sqlStr;
            DataTable dt = doh.GetDataTable();
            this._response = "{result :\"1\"," +
                "returnval :\"操作成功\"," +
                "pagerbar :\"" + Jumbot.Common.HtmlPager.GetPageBar(3, "js", 2, countNum, PSize, page, "javascript:ajaxList(<#page#>);") + "\"," +
                Jumbot.Common.JsonHelp.DtToSON(dt, (PSize * (page - 1))) +
                "}";
            dt.Clear();
            dt.Dispose();
        }
    }
}
